{include file='home/public/header' /}

<h1>这是前台！！！！12 </h1>
<p>当前有<span class="people-number">0</span>人在线,共打开了<span class="page-number">0</span>个页面浏览本网站</p>
</body>
<script type="text/javascript" src="/chat/swfobject.js"></script>
<script type="text/javascript" src="/chat/web_socket.js"></script>
<script type="text/javascript" src="/chat/jquery.min.js"></script>
<script type="text/javascript" src="/chat/jquery-sinaEmotion-2.1.0.min.js"></script>
<script type="text/javascript">
    // 如果浏览器不支持websocket，会使用这个flash自动模拟websocket协议，此过程对开发者透明
    WEB_SOCKET_SWF_LOCATION = "/swf/WebSocketMain.swf";
    // 开启flash的websocket debug
    WEB_SOCKET_DEBUG = true;
    let ws, name, client_list = {};
    ws = new WebSocket("ws://106.53.126.90:7272");
    ws.onopen = function () {
        // alert("连接成功");
    };
    // 当有消息时根据消息类型显示不同信息
    ws.onmessage = onmessage;

    // 服务端发来消息时
    function onmessage(e) {
        let data = JSON.parse(e.data);
        switch (data['type']) {
            case 'ping':
                ws.send('{"type":"pong"}');
                break;
            // 更新在线用户信息
            case 'update_online_count':
                $('.people-number').html(data['user_number']);
                $('.page-number').html(data['page_number']);
                break;
            case 'init':
                $.post('/chatBingUser', {client_id: data['client_id']}, function (res){});
                break;

        }
    }
</script>
</html>